/**
 * 
 */
package com.dalonedrau.graph;

/**
 * @author Donald
 */
public class GraphNode {
	/** the <code>GraphNode</code>'s index. must be >= 0. */
	private int	index;
	/**
	 * Creates a new instance of {@link GraphNode}.
	 */
	public GraphNode() {
		index = -1;
	}
	/**
	 * Creates a new instance of {@link GraphNode}.
	 * @param ind the index to set
	 * @throws Exception if the index <= 0
	 */
	public GraphNode(final int ind) throws Exception {
		if (ind < 0) {
			throw new Exception("Index must be greater than or equal to 0");
		}
		index = ind;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public final boolean equals(final Object obj) {
		boolean equals = false;
		if (obj instanceof GraphNode) {
			if (((GraphNode) obj).index == index) {
				equals = true;
			}
		}
		return equals;
	}
	/**
	 * Gets the the {@link GraphNode}'s index.
	 * @return <code>int</code>
	 */
	public final int getIndex() {
		return index;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public final int hashCode() {
		return super.hashCode();
	}
	/**
	 * Sets the the {@link GraphNode}'s index.
	 * @param ind the index to set
	 */
	public final void setIndex(final int ind) {
		index = ind;
	}
}
